package com.cn.date.localdate;

import java.time.LocalDate;

/**
 * 3.日期运算
 */
public class LocalDate_03_DateCalculation {
    public static void main(String[] args) {
        //3.1 加/减天、月、年
        LocalDate today = LocalDate.now();

        LocalDate nextWeek = today.plusDays(7); // 加7天
        LocalDate lastMonth = today.minusMonths(1); // 减1个月
        LocalDate nextYear = today.plusYears(1); // 加1年

        System.out.println("当前日期: " + today);
        System.out.println("下周: " + nextWeek);
        System.out.println("上个月: " + lastMonth);
        System.out.println("明年: " + nextYear);


        //3.2 比较日期
        LocalDate today1 = LocalDate.now();
        LocalDate futureDate = LocalDate.of(2025, 1, 1);

        System.out.println("今天是否在未来日期之前: " + today1.isBefore(futureDate)); // true
        System.out.println("今天是否在未来日期之后: " + today1.isAfter(futureDate)); // false
        System.out.println("今天是否等于未来日期: " + today1.isEqual(futureDate)); // false

    }
}
